package com.xjgc.eip.panel.controller;


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjgc.common.entity.ReturnResult;
import com.xjgc.eip.panel.entity.ZxjEipDnbJbwccsconclusion;
import com.xjgc.eip.panel.mapper.ZxjEipDnbJbwccsconclusionMapper;
import com.xjgc.eip.panel.service.ZxjEipDnbJbwccsconclusionService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxy
 * @since 2019-11-07
 */
@RestController
@RequestMapping("/zxjEipDnbJbwccsconclusion")
public class ZxjEipDnbJbwccsconclusionController {
    @Autowired
    private ZxjEipDnbJbwccsconclusionService zxjEipDnbJbwccsconclusionService;
    @Autowired
    private ZxjEipDnbJbwccsconclusionMapper zxjEipDnbJbwccsconclusionMapper;
    @RequestMapping("paramIntro")
    public ReturnResult paramIntro(Integer amount,@RequestHeader("supplierCode")String supplierCode){
        amount=(amount==null)?1:amount;
        Map map=new HashMap();
        map.put("amount",amount);
        map.put("SUPPLIER_CODE",supplierCode);
        List<ZxjEipDnbJbwccsconclusion> list = zxjEipDnbJbwccsconclusionMapper.selectNo(map);
        /*ZxjEipDnbJbwccsconclusion zxjEipDnbJbwccsconclusion = new ZxjEipDnbJbwccsconclusion();
        zxjEipDnbJbwccsconclusion.setIoflag(1);
        QueryWrapper<ZxjEipDnbJbwccsconclusion> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(zxjEipDnbJbwccsconclusion);
        queryWrapper.orderByAsc("\"CREATE_TIME\"");
        Page<ZxjEipDnbJbwccsconclusion> page = new Page<>(1,amount);*/
        ReturnResult returnResult = new ReturnResult();
//        List<ZxjEipDnbJbwccsconclusion> list = zxjEipDnbJbwccsconclusionService.page(page,queryWrapper).getRecords();
        returnResult.setData(list);
        if (null != list&&list.size()>0){
            for (ZxjEipDnbJbwccsconclusion zed:list){
                zed.setIoflag(0);
                zed.setGrabTime(new Date());
            }
            zxjEipDnbJbwccsconclusionService.updateBatchById(list);
        }

        return returnResult;
    }

    @RequestMapping("list")
    public Result list(@RequestHeader(value = "supplierCode" ,required = false)String supplierCode,ZxjEipDnbJbwccsconclusion zxjEipDnbJbwccsconclusion){
        String testCode = zxjEipDnbJbwccsconclusion.getTestCode();
        supplierCode = supplierCode==null?"1000069096":supplierCode;
        List<ZxjEipDnbJbwccsconclusion> list = zxjEipDnbJbwccsconclusionService.list(testCode, supplierCode);
        Page<ZxjEipDnbJbwccsconclusion> page = new Page<>();
        page.setRecords(list);
        return Result.ok(page);
    }
}

